package com.example.yangyifei_android_the_third;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class uc1 extends AppCompatActivity {
    private Button button1,backbutton1;
    private EditText t1,t2,t3,t4;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uc1);
        t1=findViewById(R.id.text1);
        t2=findViewById(R.id.text2);
        t3=findViewById(R.id.text3);
        t4=findViewById(R.id.text4);
        button1=findViewById(R.id.bn1);
        backbutton1=findViewById(R.id.bn2);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Configuration config=getResources().getConfiguration();
                String screen = config.orientation == Configuration.ORIENTATION_LANDSCAPE ?
                        "横向屏幕": "竖向屏幕";
                String mncCode = config.mnc + "";
                String naviName = config.orientation == Configuration.NAVIGATION_NONAV ? "没有方向控制": config.orientation == Configuration.NAVIGATION_WHEEL ? "滚轮控制方向": config.orientation == Configuration.NAVIGATION_DPAD ? "方向键控制方向": "轨迹球控制方向";
                String touchName = config.touchscreen == Configuration.TOUCHSCREEN_NOTOUCH ? "无触摸屏": config.touchscreen == Configuration.TOUCHSCREEN_STYLUS ? "触摸笔式触摸屏": "接受手指的触摸屏";
                t1.setText(screen);
                t2.setText(naviName);
                t3.setText(touchName);
                t4.setText(mncCode);
            }
        });
        backbutton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(uc1.this,MainActivity.class);
                startActivity(intent);
            }
        });
    }
}
